import log from '../dxmodules/dxLogger.js'
import config from '../dxmodules/dxConfig.js'

try {
    //Initialize the configuration by specifying the flag in the configuration file. Subsequent queries and modifications will require adding the flag.
    config.init({path:'/app/code/src/config.json', flag: "flag" })

    //Get all configuration items after initialization
    log.info(config.getAll('flag'))

    //Get a configuration from the configuration items
    log.info(config.get('mqtt.ip','flag'))

    //Modify one of the configuration items
    config.set("mqtt.ip",'192.168.1.1','flag')
    log.info('The modified IP address is',config.get('mqtt.ip','flag'));

    //Modify and save to local file
    config.setAndSave("mqtt.ip",'192.168.1.1','flag')
    log.info('The modified IP address is',config.get('mqtt.ip','flag'));

   
    //Reset configuration file 
    config.reset('flag')
} catch (error) {
    log.error(error.message)
    log.error(error.stack)
}